import 'package:flutter/cupertino.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:yt_devops/components/gaps.dart';
import 'package:yt_devops/components/yt_text_style.dart';
import 'package:yt_devops/resources/str_res_keys.dart';
import 'package:yt_devops/styles/styles.dart';

/**
 *
 * @Description TODO
 * @Author liuer
 * @CreateTime 2024年04月18日 15:44
 */
class ChargeOverviewWidget extends StatelessWidget {
  final String orderCount;
  final String chargeTime;
  final String chargeElectricity;
  final String orderAmount;

  const ChargeOverviewWidget(this.orderCount, this.chargeTime,
      this.chargeElectricity, this.orderAmount,
      {super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
      alignment: Alignment.center,
      decoration: const BoxDecoration(
          color: Colour.backgroundF5F5F7Color,
          borderRadius: BorderRadius.all(Radius.circular(8))),
      height: 62,
      margin: EdgeInsets.only(left: 16.w, right: 16.w),
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.center,
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Gaps.hGap10,
          _getItem(ResKey.deviceDailyChargeOrderNum.tr, orderCount,
              ResKey.order.tr), //日充订单数
          Container(
            height: 26,
            width: 0.5,
            color: Colour.grayE6TextColor,
            margin: EdgeInsets.only(right: 5.w),
          ),
          _getItem(ResKey.deviceDailyChargeHourNum.tr, chargeTime, 's'), //日充电时长
          Container(
              height: 26,
              width: 0.5,
              color: Colour.grayE6TextColor,
              margin: EdgeInsets.only(right: 5.w)),
          _getItem(ResKey.deviceDailyChargeCapacity.tr, chargeElectricity,
              'kWh'), //日充电量数
          Container(
              height: 26,
              width: 0.5,
              color: Colour.grayE6TextColor,
              margin: EdgeInsets.only(right: 5.w)),
          _getItem('', orderAmount, ResKey.yuan.tr),
          Gaps.hGap10,
        ],
      ),
    );
  }

  _getItem(
    String title,
    String value,
    String unit,
  ) {
    return Expanded(
        flex: 1,
        child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Text(title,
                  style:
                      ytTextStyle(fontSize: 12, color: Colour.otherTextColor)),
              Text.rich(
                TextSpan(
                  children: [
                    TextSpan(
                      text: value,
                      style: dinTextStyle(
                          fontSize: 18,
                          color: Colour.mainTextColor,
                          fontWeight: FontWeight.w500),
                    ),
                    TextSpan(
                        text: ' $unit',
                        style: ytTextStyle(
                          fontSize: 11,
                          color: Colour.mainTextColor,
                        )),
                  ],
                ),
              )
            ]));
  }
}
